﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenApi.Configuration
{
	public class OpenApiConfigurationSection : ConfigurationSection
	{
		public static OpenApiConfigurationSection Root = GetRoot();

		/// <summary>
		/// openApi/default配置节。
		/// </summary>
		[ConfigurationProperty("default")]
		public DefaultElement Default
		{
			get
			{
				return (DefaultElement)this["default"];
			}
			set
			{
				this["default"] = value;
			}
		}

		/// <summary>
		/// openApi/services配置节。
		/// </summary>
		[ConfigurationProperty("services")]
		[ConfigurationCollection(typeof(OpenApiServiceElement), AddItemName = "service")]
		public OpenApiServiceElementCollection Services
		{
			get
			{
				return (OpenApiServiceElementCollection)this["services"];
			}
			set
			{
				this["services"] = value;
			}
		}

		private OpenApiConfigurationSection() { }

		private static OpenApiConfigurationSection GetRoot()
		{
			return ConfigurationManager.GetSection("openApi") as OpenApiConfigurationSection;
		}
	}
}
